﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using EQT.Dal;
using EQT.Model;

public partial class MyTaskListV2 : System.Web.UI.Page
{
    private static readonly Common.Logging.ILog log = Common.Logging.LogManager.GetCurrentClassLogger();
    private DaContractTask dalTask = DevFuture.Common.WorkContext.AppCtx.GetObject("DaContractTask") as DaContractTask;

    private UserContext context;

    protected void Page_Load(object sender, EventArgs e)
    {
        context = Session["USER_CONTEXT"] as UserContext;
        OperationResult.Text = "";
        divResult.Visible = false;
        if (!IsPostBack)
        {
            AspNetPager.PageSize = 15;

            this.BtnQuery_Click(null, null);

        }
    }

    protected void AspNetPager_PageChanged(object sender, EventArgs e)
    {
        this.BtnQuery_Click(null, null);
    }

    protected void BtnQuery_Click(object sender, EventArgs e)
    {
        //这里查询任务信息并绑定到gridview上。
        int pagecount = 0;
        string strCondition = "where 1=1 ";

        if (sender != null && e != null)
        {
            AspNetPager.CurrentPageIndex = 0;
        }

        if (!string.IsNullOrEmpty(txtReportID.Text.Trim()))
        {
            strCondition = strCondition + "and  Report_ID='" + txtReportID.Text.Trim() + "'";
        }
        if (!string.IsNullOrEmpty(ddlStatus.SelectedValue))
        {
            strCondition = strCondition + "and  CT_Status=" + ddlStatus.SelectedValue + "";
        }


        strCondition = strCondition + "and  CT_Tester_ID='" + context.UserID + "'";
        
        this.TaskGridView.DataSource = dalTask.GetTaskList(strCondition, AspNetPager.PageSize, AspNetPager.CurrentPageIndex - 1, out pagecount);

        TaskGridView.DataBind();

        AspNetPager.RecordCount = pagecount;

    }
}
